//
// Created by lenovo on 24-12-25.
//

#include <iostream>
#include <vector>
using namespace std;

class Solution
{
public:
    static string multiply(string num1, string num2)
    {
        if(num1 == "0" || num2 == "0")
            return "0";

        int l1 = num1.size();
        int l2 = num2.size();
        pmr::vector<int> ret(l1+l2,0);

        for(int i=l1-1; i>=0; i--)
        {
            for(int j=l2-1; j>=0; j--)
            {
                int mul = (num1[i]-'0') * (num2[j]-'0');
                int sum = mul + ret[i+j+1];
                ret[i+j+1] = sum%10;
                ret[i+j] += sum/10;
            }
        }

        string rs;
        for(int e : ret)
        {
            if(e != 0 || !rs.empty())
            {
                rs += (e + '0');
            }
        }
        return rs;
    }
};